package com.glsc.ngateway.common.base.dto.cmdb;


import cn.hutool.core.annotation.Alias;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang.StringUtils;


/**
 * 整机详情导入 数据结构
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude
@SuperBuilder
public class CmdbDeviceDetailImportDto {

    @Alias(value = "名称")
    @ApiModelProperty(value = "名称")
    private String name;

    @Alias(value = "序列号")
    @ApiModelProperty(value = "序列号")
    private String sn;

    @Alias(value = "出厂日期")
    @ApiModelProperty(value = "出厂日期")
    private String manufactDate;

    @Alias(value = "过保日期")
    @ApiModelProperty(value = "过保日期")
    private String expirateDate;

    @Alias(value = "机房")
    @ApiModelProperty(value = "机房")
    private String machineRoom;

    @Alias(value = "购置日期")
    @ApiModelProperty(value = "购置日期")
    private String purchaseDate;

    @Alias(value = "设备类型")
    @ApiModelProperty(value = "设备类型")
    private String deviceTypeName;

    @Alias(value = "入库单价（含税）")
    @ApiModelProperty(value = "入库单价（含税）")
    private String inputPriceWithTax;

    @Alias(value = "不含税金额")
    @ApiModelProperty(value = "不含税金额")
    private String inputPriceNoTax;

    @Alias(value = "使用人")
    @ApiModelProperty(value = "使用人")
    private String user;

    @Alias(value = "设备规格名称")
    @ApiModelProperty(value = "设备规格名称")
    private String deviceStandardName;


    @ApiModelProperty(value = "规格编号，不参与导入导出，参与页面逻辑")
    private String deviceStandardCode;

    private Integer machineRoomId;
    private Integer deviceTypeId;
    private String model;


    public String getManufactDate() {
        if (StringUtils.isNotBlank(manufactDate)) {
            return manufactDate.substring(0, 10);
        }
        return null;
    }

    public String getExpirateDate() {
        if (StringUtils.isNotBlank(expirateDate)) {
            return expirateDate.substring(0, 10);
        }
        return null;
    }

    public String getPurchaseDate() {
        if (StringUtils.isNotBlank(purchaseDate)) {
            return purchaseDate.substring(0, 10);
        }
        return null;
    }
}
